package com.easy.modules.sysmgr.web.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.easy.common.util.Const;
import com.easy.common.web.BaseController;
import com.easy.common.web.page.Msg;
import com.easy.modules.sysmgr.service.PositionServiceI;
import com.easy.modules.sysmgr.web.form.PositionForm;

@Controller
@RequestMapping("/sysmgr/position")
public class PositionAction extends BaseController {
	
	@Autowired
	private PositionServiceI positionService ;
	
	@RequestMapping("/position_main.do")
	public String position_main() throws Exception {
		return Const.SYSMGR + "position_main" ;
	}
	
	@RequestMapping("/position_form.do")
	public String position_form(PositionForm form, HttpServletRequest request) throws Exception {
		if(null != form.getId() && !"".equals(form.getId())) {
			request.setAttribute("id", form.getId()) ;
		}
		return Const.SYSMGR + "position_form" ;
	}
	
	@RequestMapping("/get.do")
	@ResponseBody
	public PositionForm get(PositionForm form, HttpServletRequest request) throws Exception {
		return this.positionService.get(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_get.do")
	@ResponseBody
	public PositionForm doNotNeedAuth_get(PositionForm form, HttpServletRequest request) throws Exception {
		return this.positionService.get(form) ;
	}
	
	@RequestMapping("/add.do")
	@ResponseBody
	public Msg add(PositionForm form) throws Exception {
		return this.positionService.save(form) ;
	}
	
	@RequestMapping("/edit.do")
	@ResponseBody
	public Msg edit(PositionForm form) throws Exception {
		return this.positionService.edit(form) ;
	}
	
	@RequestMapping("/delete.do")
	@ResponseBody
	public Msg delete(PositionForm form) throws Exception {
		return this.positionService.delete(form) ;
	}
	
	@RequestMapping("/tree.do")
	@ResponseBody
	public List<PositionForm> treegrid(PositionForm form ,String mode) throws Exception {
		return this.positionService.tree(form) ;
	}
	
	@RequestMapping("/doNotNeedAuth_tree.do")
	@ResponseBody
	public List<PositionForm> treebox(PositionForm form ,String mode) throws Exception {
		return this.positionService.tree(form) ;
	}

}
